home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1996 #15
/
Monster Media Number 15 (Monster Media)(July 1996).ISO
/
os2
/
srefv112.zip
/
INSTALL.CMD
< prev
next >
Wrap
OS/2 REXX Batch file
|
1996-05-26
|
22KB
|
763 lines
/* this is the SRE-FILTER installation program */
/* Load up advanced REXX functions */
call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
call SysLoadFuncs
copyall=0
echo off
/* --- Load the tcp/ip function library, if necessary --- */
if RxFuncQuery("SockLoadFuncs")=1 then do /* not there */
call RxFuncAdd "SockLoadFuncs","rxSock","SockLoadFuncs"
call SockLoadFuncs
end
ansion=checkansi()
if ansion=1 then do
aesc='1B'x
cy_ye=aesc||'[37;46;m'
normal=aesc||'[0;m'
bold=aesc||'[1;m'
re_wh=aesc||'[31;47;m'
reverse=aesc||'[7;m'
end
else do
cy_ye="" ; normal="" ; bold="" ;re_wh="" ;
reverse=""
end /* Do */
cls
say " " ; say
call lineout, bold cy_ye
call lineout, "This is the SRE-FILTER (v 1.11) installation program (5/96). "
call lineout, "... an HTTP filter for the GoServe OS/2 Internet Server "
call lineout, normal
say " This program will ask for the names of a few directories,"
say " and will copy a number of files to these directories."
say " "
if yesno(" Are you ready to continue ")=1 then
say " Okay ... "
else do
say " See you later?.. "
exit
end
say " First,what is your IP address (it will be given OWNER privileges)"
ipaddr=" "
sagain:
call charout , bold " What is your IP address:? " normal
pull youraddr
parse var youraddr t1 '.' .
isnum=0
if datatype(t1)='NUM' then
isnum=1
say " wait while that address is checked ... "
chk=host(youraddr)
if translate(word(chk,2))<>"IS" then do
call lineout,re_wh " Unable to find address: " youraddr normal
say " OWNER variable not assigned (but you can assign it later)"
ipaddr=" "
end /* Do */
else do
if isnum then
ipaddr=word(chk,1)
else
ipaddr=word(chk,3)
say " Your IP address: " ipaddr
end
skip:
nowdir=directory()
adir=filespec("drive",nowdir)
defname=adir||'\GOSERV'
defname2=adir||'\GOHTTP'
skip:
/* -------- Working directory (must exist ) */
say
call lineout, cy_ye " Please enter a few directory names: " normal
say " "
call lineout, bold " What is GOSERVE's "working" directory? " normal
say " ... the SRE-FILTER program files will be written there. "
n1:
godir=get_dir(defname)
if godir=" " then godir=defname
if godir="n.a." then signal n1
godir=strip(godir,'t','\')
gsname=godir||"\GOSERVE.EXE"
call sysfiletree gsname,gname2,'F'
if gname2.0=0 then do
say " Could not find GOSERVE.EXE in " godir "...."
if yesno(" Do you want to use it anyways?")=1 then signal useit0
if godir=defname then defname= "n.a."
signal n1
end /* Do */
useit0: workdir=godir
say " "
/* -- Get the DATA subdirectory of the working directory */
say " "
say " Where should SRE-FILTER's Message, Access, & Counter files be installed?"
say " .. it is recommended that it be under your working directory ! "
sdatadir=get_dir(workdir||'\DATA')
/* -- Get the UpLOAD subdirectory of the working directory */
say " "
say " Where should SRE-FILTER store Uploaded files?"
upload_dir=get_dir(workdir||'\upload')
/* -- Get the CGI-BIN directory of the working directory */
say " "
say " Where should CGI-BIN files be stored? "
cgibin_dir=get_dir(workdir||'\cgi_bin')
/* -- Get the data directory */
say " "
call lineout, bold " What is your data directory?" normal
say ' .. this is the location of your "home page" '
datadir=get_dir(defname2)
/* -- Get the IMGS subdirectory of the data directory */
say " "
say " Where should SRE-FILTER's GIF files be installed?"
say " .. it should be under your data directory ! "
gifdir=get_dir(datadir||'\IMGS')
/* -- The "sample and help files" directory */
say " "
say " Where should the Sample and Help Files be installed?"
say " .. it MUST be under your data directory ! "
helpdir=get_dir(datadir||'\SAMPLES',datadir)
/* -- The "temporary directory" -- */
say " "
say " Where should SRE-FILTER's Temporary Directory be "
say " ... it's recommended, but not required, that this be under "
say " your data directory "
tempdir=get_dir(datadir||'\TEMP')
eek=godir||'\srefiltr.*'
call sysfiletree eek,gname3,'F'
/* -- Done with directory creation -- copy files ... */
say " "
call lineout, re_wh "WARNING: " normal
call lineout, bold " If you are re-installing SRE-FILTER, older files may be overwritten." normal
say " If you have made extensive changes to parameter files, "
say " you may want to back them up before completing this installation."
foo=yesno(" Files will now be copied to these directories. Are you ready? ")
if foo=0 then do
say " Try again later... "
exit
end
say " "
say " Copying miscellaneous SRE-FILTER program files files to " workdir
foo=check_copy('*.80' ,workdir)
say " Copying user configurable parameter files to " workdir
foo=check_copy('*.IN', workdir,' *** THESE ARE USER CONFIGURED FILES : Are you sure?')
foo=check_copy('*.RXX',workdir)
foo=check_copy('*.RXL',workdir)
foo=check_copy('MACROEYE.CMD',workdir)
foo=check_copy('REXXLIB.DLL',workdir)
foo=check_copy('*.CON',workdir)
foo=check_copy('*.SWI',workdir)
foo=check_copy('XCOUNT.CMD',cgibin_dir)
foo=check_copy('TEST-CGI.CMD',cgibin_dir)
say " Copying access control, tracking, and message boxes to " sdatadir
foo=check_copy('*.CTL',sdatadir,' These are your access control files: Are you sure?')
foo=check_COPY('*.CNT', sdatadir,' These are your "hit-counter" files: Are you sure?')
foo=check_COPY('*.LOG', sdatadir,' This is your default "message box": Are you sure?')
say " Copying sample and help files to " helpdir
foo=check_COPY('*.HTM',helpdir)
foo=check_COPY('*.key',helpdir)
foo=check_COPY('*.DAT',helpdir)
foo=check_COPY('*.DOC',helpdir)
foo=check_COPY('*.MAP',helpdir)
foo=checK_COPY('SAMPMAP.GIF',helpdir)
foo=check_COPY('TESTTABL.TBL',HELPDIR)
foo=check_COPY('TESTTABL.DEF',HELPDIR)
SAY ' Copying GIF file archive to ' gifdir
foo=check_COPY('GIFS.ZIP',gifdir)
meis=directory()
gifis=directory(gifdir)
'UNZIP GIFS.ZIP'
meis=directory(meis)
/* --- customize index.htm -- */
say " "
call lineout, cy_ye " ... customizing files ... " normal
say " "
say ' Copying sample home page to ' datadir
thefh=grab_file("INDEX.HT0")
if thefh=0 then do
Say " ERROR : Could not find sample home page "
say " You may need to unzip SREFILTR.ZIP again? "
signal done1
end
parse var helpdir foo (datadir) thesamp
thesamp=strip(translate(thesamp,'/','\'),,'/')
thefh=replacestrg(thefh,'helpdirectory',thesamp,'ALL')
dog=datadir||'\INDEX.HTM'
drop foo1
tmp=sysfiletree(dog,foo1,'F')
ok=1
if foo1.0>0 & copyall=0 then
ok=yesno(" Overwrite "||dog"?")
if ok=1 then do
foo=sysfiledelete(dog) /* delete any prior version */
aa=stream(dog,'c','open write')
if aa<>'READY:' then do
say " ERROR: could not write " dog
signal done1
end
foo=charout(dog,thefh)
if foo>0 then do
say " ERROR: Problem writing " dog
signal done1
end
aa=stream(dog,'c','close')
end
/*--- Customize IMAGE MAP DEMO --- */
say ' Customizing IMAGE MAP demo document '
thefh=grab_file("SAMPMAP.HT0")
if thefh=0 then do
Say " ERROR : Could not find IMAGE MAP demo document "
say " You may need to unzip SREFILTR.ZIP again? "
signal done1
end
thefh=replacestrg(thefh,'helpdirectory',thesamp,'ALL')
dog=helpdir||'\SAMPMAP.HTM'
drop foo1
tmp=sysfiletree(dog,foo1,'F')
ok=1
if foo1.0>0 & copyall=0 then
ok=yesno(" Overwrite "||dog"?")
if ok=1 then do
foo=sysfiledelete(dog) /* delete any prior version */
aa=stream(dog,'c','open write')
if aa<>'READY:' then do
say " ERROR: could not write " dog
signal done1
end
foo=charout(dog,thefh)
if foo>0 then do
say " ERROR: Problem writing " dog
signal done1
end
aa=stream(dog,'c','close')
end
/*-- Customize FILTINST.HTM --- */
say " Creating SRE-FILTER configurator (FILTINST.HTM) for your system "
thefh=grab_file("FILTINST.HT0")
if thefh=0 then do
Say " ERROR : Could not find FILTINST configurator program. "
say " You may need to unzip SREFILTR.ZIP again? "
signal done1
end
thefh=replacestrg(thefh,'helpdirectory',thesamp,'ALL')
dog=datadir||'\FILTINST.HTM'
drop foo1
tmp=sysfiletree(dog,foo1,'F')
ok=1
if foo1.0>0 & copyall=0 then
ok=yesno(" Overwrite "||dog"?")
if ok=1 then do
foo=sysfiledelete(dog) /* delete any prior version */
aa=stream(dog,'c','open write')
if aa<>'READY:' then do
say " ERROR: could not write " dog
signal done1
end
foo=charout(dog,thefh)
if foo>0 then do
say " ERROR: Problem writing " dog
signal done1
end
aa=stream(dog,'c','close')
say " "
'COPY ' dog workdir ' > nul '
end
/* --- Modifying the FILTER program ---- */
looksdir="servdir='workingdirectory'"
say " Modifying SREFILTR.80 (the main filter program) "
thefh=grab_file("SREFILTR.A80")
if thefh=0 then do
Say " ERROR : Could not find SREFILTR.A80 parameters file. "
say " You may need to unzip SREFILTR.ZIP again? "
signal done1
end
looksdir2="servdir='"||workdir||"'"
thefh=replacestrg(thefh,looksdir,looksdir2)
dog=workdir||'\SREFILTR.80'
drop foo1
tmp=sysfiletree(dog,foo1,'F')
ok=1
if foo1.0>0 & copyall=0 then
ok=yesno(" Overwrite "||dog"?")
if ok=1 then do
foo=sysfiledelete(dog) /* delete any prior version */
aa=stream(dog,'c','open write')
if aa<>'READY:' then do
say " ERROR: could not write " dog
signal done1
end
foo=charout(dog,thefh)
if foo>0 then do
say " ERROR: Problem writing " dog
signal done1
end
aa=stream(dog,'c','close')
end
/*-- Modifying the INITFILT.80 file -- */
say " "
say " Modifying the INITFILT.80 parameters file "
thefh=grab_file("INITFILT.A80")
if thefh=0 then do
Say " ERROR : Could not find INITFILT.A80 parameters file. "
say " You may need to unzip SREFILTR.ZIP again? "
signal done1
end
thefh=replacestrg(thefh,'workingdirectory',workdir,'ALL')
thefh=replacestrg(thefh,'workingdir',workdir,'ALL')
thefh=replacestrg(thefh,'workingdatadir',sdatadir,'ALL')
thefh=replacestrg(thefh,'temporarydir',tempdir,'ALL')
thefh=replacestrg(thefh,'owneraddress',ipaddr,'ALL')
thefh=replacestrg(thefh,'uploaddir',upload_dir,'ALL')
thefh=replacestrg(thefh,'cgibindirectory',cgibin_dir,'ALL')
dog=workdir||'\INITFILT.80'
drop foo1
tmp=sysfiletree(dog,foo1,'F')
ok=1
if foo1.0>0 & copyall=0 then do
ok=yesno(" Overwrite "||dog"?")
if ok=1 then do
say dog " is your server-configuration file... "
ok=yesno(" are you sure you want to overwrite it?")
end
end
if ok=1 then do
foo=sysfiledelete(dog) /* delete any prior version */
aa=stream(dog,'c','open write')
if aa<>'READY:' then do
say " ERROR: could not write " dog
signal done1
end
foo=charout(dog,thefh)
if foo>0 then do
say " ERROR: Problem writing " dog
signal done1
end
aa=stream(dog,'c','close')
end
done1: nop
call charout , cy_ye ' (hit any key to continue) ' normal
foo=sysgetkey("noecho")
say " "
say " -------------------------------- "
say " "
poop:
call lineout, bold cy_ye " SRE-FILTER has been installed... " normal
say " ... but there a few things you must do."
say " 1) Instruct GoServe that SREFILTR.80 is the working filter "
say " (use the OPTIONS-FILTER tab in the GoServe status window)"
say " 2) Make sure that GoServe knows your data directory "
say " (use the OPTIONS-DataDir tab in the GoServe status window) "
say ' 3) To customize SRE-FILTER, you should "run" FILTINST.HTM '
say " "
say " (actually, you should probably read the documentation first!) "
say " "
say " To do this (while still at the server): "
say " a) Fire up your favorite web browser (say, IBM Web Explorer 1.03)"
say ' b) Get /FILTINST.HTM (in the data-directory of your server)'
say ' c) Select the "change parameter values options" '
say " d) A big fill-in form, listing the current value of SRE-FILTER's "
say ' user-configurable parameters, and a short description of what '
say ' they do, will appear '
say ' e) Fill in the form and submit it. '
say ' '
call charout , cy_ye ' (hit any key to continue) ' normal
foo=sysgetkey("noecho")
say " "
say " As a security feature, before the configurator is run, FILTINST "
say " checks that the Server and Client addresses match. "
say " If they do not, then you will be denied access. "
say " If you want to live dangerously, you can suppress this security feature"
say ' by commenting out the "CHECKIT=1" line near the top of '
say " FILTINST.80 (in your " workdir " directory )"
say " (actually, we recommend deleting FILTINST.HTM from " datadir
say " .. it's a potential security hole) "
say " "
say ' Note that FILTINST.HTM has links to a few "help" documents:'
say ' i) SUMMARY.HTM -- a summary of SRE-FILTER '
say " ii) INITFILT.DOC -- a detailed description of the SRE-FILTER's "
say ' parameters, with possible choices described for each. '
say ' iii) SREFILTR.HTM -- the complete documentation '
say ' '
call charout , cy_ye ' (hit any key to continue) ' normal
foo=sysgetkey("noecho")
say ' '
say bold ' A Note on ports: ' normal ' If you can not use port 80, all you need to do is '
say ' change all the *.80 files (to *.new_port_number) -- see the '
say ' documentation for details '
say ' '
say ' Your web site is now ready to be built! '
say ' (just add documents, images, links, etc...)'
say ' '
say ' Notes: You can use INDEX.HTM '
say ' in your data directory (' datadir ') as a template. '
say ' If you use a different File name as your "home page",'
say " be sure to set SRE-FILTER's " bold "DEFAULT " normal " variable to point to it. "
say ' '
say ' Good luck.'
say ' '
call lineout, bold ' (if you have problems, you can contact DANIELH@ECON.AG.GOV )' normal
exit
/* ----------------------------------------------------------------------- */
/* HOST -- return the result of a HOST command (a ping ) */
/* ----------------------------------------------------------------------- */
/* This need not be in the main filter program */
/* It returns the GoServe command to send back the result */
host: procedure
do queued(); pull .; end /* flush */
address cmd '@host' arg(1) '| rxqueue' /* execute the command */
parse pull hostresult /* get result */
return hostresult
/*
crlf='0d0a'x
return 'STRING host' arg(1)':'crlf crlf''hostresult
*/
/* -------------------- */
/* get a yes or no , return 1 if yes */
yesno:procedure expose normal reverse bold
parse arg fooa , allopt
ayn=' '||bold||'Y'||normal||'es\'||bold||'N'||normal||'o'
if allopt=1 then
ayn=ayn||'\'||bold||'A'||normal||'ll'
do forever
foo1=normal||reverse||fooa||normal||ayn
call charout, foo1 normal ':'
pull anans
if abbrev(anans,'Y')=1 then return 1
if abbrev(anans,'N')=1 then return 0
if allopt=1 & abbrev(anans,'A')=1 then return 2
end
/* ------------------------ */
/* ask for directory name,use defname2 as default */
/* give user opportunity to create it */
get_dir:procedure expose normal reverse bold
/* procedure expose reverse normal bold */
parse arg defname2 , mustsub
defname0=defname2
n2:
call charout , reverse ' <ENTER>=' defname2 normal ' ?'
pull godir
if godir=" " then godir=defname2
if godir="n.a." then signal n2
if mustsub<>"" then do /* check 'must be subdirectory' option */
if abbrev(godir,mustsub)=0 then do
say " This directory MUST be under the " mustsub " directory! "
say " .. please re enter ! "
signal n2
end
end
godir=strip(godir,'t','\')
gdname=godir||"\*.*"
isme=directory()
isnew=directory(godir)
if isnew="" then do
say " Could not find " godir
if yesno(" Would you like to create it")=1 then do
oo=sysmkdir(godir)
if oo=0 then
say " Directory created: " godir
else do
say " Could not create " godir "(error = " oo
if godir=defname2 then defname2= "n.a."
signal n2
end
end
else do
say " please reenter directory name ... "
if godir=defname2 then defname2= "n.a."
signal n2
end
end /* Do */
isme=directory(isme)
return godir
/* ------------- */
* ----------------------------------------------------------------------- */
/* REPLACESTRG: In string astring, find first occurence substring target and
. replace it with substring putme
. if no target, return unchanged astring
. if no putme, then remove target
. if type=backward, then find/change LAST occurence
. if type=all, find/change all occurences
. if exactmatch=yes, then do not capitalize during search (exact match only */
/* ----------------------------------------------------------------------- */
replacestrg: procedure
exactmatch=0
backward=0 ; doall=0
parse arg astring , target , putme , type , exactmatch
type = translate(type)
if type="BACKWARD" then backward="YES"
if type="ALL" then doall="YES"
iat=1
joelen=length(target)
joelen2=length(putme)
doagain: /* here if doall=yes */
if exactmatch="YES" then do
if backward="YES" then
joe= lastpos(target,astring)
else
joe= pos(target,astring,iat)
end
else do
if backward="YES" then
joe= lastpos(translate(target),translate(astring))
else
joe= pos(translate(target),translate(astring),iat)
end
if joe=0 then
return astring
astring=delstr(astring,joe,joelen)
if putme<>' ' then
astring=insert(putme,astring,joe-1)
if doall="YES" then do
iat=joe+joelen2
signal doagain
end
/* else, all done */
return astring
/* ----------------------------------------------------------------------- */
/* GRAB_FILE read in a file, but first check to see if openable, and if
. openable, open and read it.
. Returns with the file, or with 0 if file not obtainable.
. Note that file is closed before returning
. in,
. usage: afile_string=grab_file(the_file,seconds_to_try_for)
*/
/* ----------------------------------------------------------------------- */
grab_file: procedure
parse arg afile
ause=stream(afile,'c','open read')
if ause<>"READY:" then
return 0
goo=charin(afile,1,chars(afile))
ause=stream(afile,'c','close')
/* get rid of ending ctl-z */
if c2d(right(goo,1))=26 then
goo=left(goo,length(goo)-1)
return goo
/*******************************************/
/* check for existence of file, then ask user to copy or not */
/* note that for X.* type copies, it only checks once
(not for each file, but just for any one of them */
/********************************************/
check_copy: procedure expose copyall reverse bold normal
parse arg file1, dest1 , amess
dest2=strip(dest1,'t','\')||'\'
filename=dest2||file1
if copyall=1 then signal doit3
aa=sysfiletree(filename,isit,'F')
ok=1
if aa<>0 then do
say " Warning: error when looking for pre-existing copy of: " filename
ok=yesno(" Do you want to copy this file (or files) anyways? ")
if ok=1 & amess<>"" then
ok=yesno(amess)
end
if isit.0>0 then do
if pos('*',file1)=0 then do
say " "
say " A file exists with the name: " filename
ok=yesno(" Do you want to overwrite this file? ",1)
if ok=1 & amess<>"" then
ok=yesno(amess)
end
else do
say " "
say " There is at least one file that matches: " filename
say " (this match may " bold " not " normal " be one of the files that will be copied!) "
ok=yesno(" Do you want to copy these files? ",1)
if ok=1 & amess<>"" then
ok=yesno(amess)
end /* Do */
end
if ok=2 then do
say " "
say "SRE-FILTER will overwrite all files (not just these) "
copyall=yesno(" Are you sure you want to do this?")
if copyall=0 then
ok=yesno(" Do you want to overwrite the current file (or files)? ")
end
if ok=0 then return 0
doit3: /* jump here if copyall is on */
'COPY ' file1 dest1 ' > NUL '
return 1
/* ------------------------------------------------------------------ */
/* function: Check if ANSI is activated */
/* */
/* call: CheckAnsi */
/* */
/* where: - */
/* */
/* returns: 1 - ANSI support detected */
/* 0 - no ANSI support available */
/* -1 - error detecting ansi */
/* */
/* note: Tested with the German and the US version of OS/2 3.0 */
/* */
/* */
CheckAnsi: PROCEDURE
thisRC = -1
trace off
/* install a local error handler */
SIGNAL ON ERROR Name InitAnsiEnd
"@ANSI 2>NUL | rxqueue 2>NUL"
thisRC = 0
do while queued() <> 0
queueLine = lineIN( "QUEUE:" )
if pos( " on.", queueLine ) <> 0 | , /* USA */
pos( " (ON).", queueLine ) <> 0 then /* GER */
thisRC = 1
end /* do while queued() <> 0 */
InitAnsiEnd:
signal off error
RETURN thisRC